import numpy as np

class Task47:
    def run(self, values):
        rows, cols = values.shape
        profits = np.zeros(cols)

        profits[0] = values[0][0]
        for j in range(1, cols):
            profits[j] = profits[j - 1] + values[0][j]

        for i in range(1, rows):
            profits[0] = profits[0] + values[i][0]
            for j in range(1, cols):
                profits[j] = max(profits[j], profits[j - 1]) + values[i][j]

        return profits[cols - 1]
